package com.smtx.bundle.internal;

import com.smtx.service.Service;
import com.smtx.service.ServiceManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.ContextStartedEvent;

/**
 * Created by IntelliJ IDEA.
 * User: Cyril
 * Date: 20.05.11
 * Time: 0:18
 * To change this template use File | Settings | File Templates.
 */
public class OntologyActivatorAware implements ApplicationListener {
    @Autowired
    public Integer test;

    @Autowired
    public ServiceManager serviceManager;

    @Override
    public void onApplicationEvent(ApplicationEvent applicationEvent) {
        System.out.println( String.format("OntologyActivatorAware::onApplicationEvent invoked (%s)",
                applicationEvent.getClass().getName()) );
        if (applicationEvent instanceof ContextStartedEvent || applicationEvent instanceof ContextRefreshedEvent) {
            System.out.println( "Size is: " + serviceManager.listServices().size() );
            for (Service s : serviceManager.listServices())
                System.out.println( " --> Service: " + s.getName() );
        }
    }
}
